function idyoz = genshock(zmat,ztran,muz,sz,nhh,Jy,ini)

% ini=0, no initial vector, use muz and sz create initial vector
% ini~=0, use initial vector

if ini==0
% global zmat ztran
   
    idyoz    = zeros(nhh,Jy);
    
    inidis   = muz+sz*randn(nhh,1);

for i = 1:nhh
    idyoz(i,1) = zmat(close(zmat,inidis(i)));
end

else
    idyoz = ini;

% AR(1)
for j = 2:Jy
    for i=1:nhh
        prevz = close(zmat,idyoz(i,j-1));
        idyoz(i,j) = zmat(gendist(ztran(prevz,:),1,1));

    end
end
    
end
